package com.example.javabase.DesignPattern.Strategy;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: wyb
 * @date: 2021/11/3 16:41
 * @describe:
 * @vision 1.0
 */
@Controller
public class TestController {
    @Resource
    private Map<String,AbstractInstrCalculateHandler> instrCalculateHandler;

    @GetMapping("/getMsgCallBack")
    @ResponseBody
    public Object getMsgCallBack(Integer type) throws Exception {
        String beanName = InstrCalculateEnum.getClassName(type);
        AbstractInstrCalculateHandler abstractInstrCalculateHandler = this.instrCalculateHandler.get(beanName);
        HashMap<String, Object> map = new HashMap<>();
        map.put("a","4");
        map.put("b","3");
        return abstractInstrCalculateHandler.excute("a/b", map);

    }
}

